//
//  MXHomeFashionTableViewCell.m
//  MXの衣柜
//
//  Created by 马霄 on 15/8/10.
//  Copyright (c) 2015年 霄 马. All rights reserved.
//

#import "MXHomeFashionTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface MXHomeFashionTableViewCell ()
/**
 * 设置主图片
 */
@property (nonatomic, retain) UIImageView *mainImageView;
/**
 * 设置潮品的详情
 */
@property (nonatomic, retain) UILabel *detailLabel;
/**
 * 设置潮品的标语
 */
@property (nonatomic, retain) UILabel *titleLabel;
/**
 * 设置潮品的描述
 */
@property (nonatomic, retain) UILabel *descriptionLabel;
/**
 * 设置潮品的价格
 */
@property (nonatomic, retain) UILabel *priceLabel;
/**
 * 设置潮品的小图标
 */
@property (nonatomic, retain) UIImageView *StarImageView;
/**
 * 设置潮品的分割线
 */
@property (nonatomic, retain) UIView *line;
@end
@implementation MXHomeFashionTableViewCell

- (void)dealloc
{
    [_StarImageView release];
    [_titleLabel release];
    [_descriptionLabel release];
    [_priceLabel release];
    [_fashionModelS release];
    [_mainImageView release];
    [_detailLabel release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.mainImageView = [[[UIImageView alloc] init] autorelease];
        self.mainImageView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:self.mainImageView];
        
        self.detailLabel = [[[UILabel alloc] init] autorelease];
        self.detailLabel.backgroundColor = [UIColor blackColor];
        self.detailLabel.alpha = 0.2;
        self.detailLabel.text = @"";
        self.detailLabel.alpha = 1;
        self.detailLabel.numberOfLines = 2;
        self.detailLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:self.detailLabel];
        
        self.titleLabel = [[[UILabel alloc] init] autorelease];
        self.titleLabel.backgroundColor = [UIColor clearColor];
        self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
        [self.titleLabel setTextColor:[UIColor whiteColor]];
        [self.detailLabel addSubview:self.titleLabel];
        
        self.descriptionLabel = [[[UILabel alloc] init] autorelease];
        self.descriptionLabel.backgroundColor = [UIColor clearColor];
        self.descriptionLabel.font = [UIFont systemFontOfSize:14];
        [self.descriptionLabel setTextColor:[UIColor whiteColor]];
        [self.detailLabel addSubview:self.descriptionLabel];
        
        self.priceLabel = [[[UILabel alloc] init] autorelease];
        self.priceLabel.backgroundColor = [UIColor clearColor];
        [self.priceLabel setTextColor:[UIColor whiteColor]];
        self.priceLabel.font = [UIFont systemFontOfSize:16];
        [self.detailLabel addSubview:self.priceLabel];
        
        self.StarImageView = [[[UIImageView alloc] init] autorelease];
        self.StarImageView.image = [UIImage imageNamed:@"Star"];
        [self.detailLabel addSubview:self.StarImageView];
        
        self.line = [[[UIView alloc] init] autorelease];
        self.line.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.line];

    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    
    
    CGFloat mainImageViewX = 0;
    CGFloat mainImageViewY = 0;
    CGFloat mainImageViewW = self.frame.size.width;
    CGFloat mainImageViewH = HEIGHT / 667 * 400;
    self.mainImageView.frame = CGRectMake(mainImageViewX, mainImageViewY, mainImageViewW, mainImageViewH);
    
    CGFloat detailLabelX = 0;
    CGFloat detailLabelY = mainImageViewH - WIDTH / 375 * 60;
    CGFloat detailLabelW = mainImageViewW;
    CGFloat detailLabelH = HEIGHT / 667 * 60;
    self.detailLabel.frame = CGRectMake(detailLabelX, detailLabelY, detailLabelW, detailLabelH);
    
    CGFloat titleLabelX = 0;
    CGFloat titleLabelY = 0;
    CGFloat titleLabelW = mainImageViewW - 130;
    CGFloat titleLabelH = HEIGHT / 667 * 30;
    self.titleLabel.frame = CGRectMake(titleLabelX, titleLabelY, titleLabelW, titleLabelH);
    
    CGFloat descriptionLabelX = 0 + WIDTH / 375 * 30;
    CGFloat descriptionLabelY = titleLabelH;
    CGFloat descriptionLabelW = titleLabelW;
    CGFloat descriptionLabelH = titleLabelH;
    self.descriptionLabel.frame = CGRectMake(descriptionLabelX, descriptionLabelY, descriptionLabelW, descriptionLabelH);
    
    CGFloat StarImageViewX = 0;
    CGFloat StarImageViewY = titleLabelH;
    CGFloat StarImageViewW = WIDTH / 375 * 30;
    CGFloat StarImageViewH = HEIGHT / 667 * 30;
    self.StarImageView.frame = CGRectMake(StarImageViewX, StarImageViewY, StarImageViewW, StarImageViewH);
    
    CGFloat priceLabelX = mainImageViewW - WIDTH / 375 * 100 + WIDTH / 375 * 20;
    CGFloat priceLabelY = HEIGHT / 667 * 10;
    CGFloat priceLabelW = WIDTH / 375 * 60;
    CGFloat priceLabelH = HEIGHT / 667 * 40;
    self.priceLabel.frame = CGRectMake(priceLabelX, priceLabelY, priceLabelW, priceLabelH);
    
    CGFloat lineX = priceLabelX - WIDTH / 375 * 20;
    CGFloat lineY = detailLabelH / 2 + mainImageViewH - HEIGHT / 667 * 80;
    CGFloat lineW = WIDTH / 375 * 2;
    CGFloat lineH = HEIGHT / 667 * 40;
    self.line.frame = CGRectMake(lineX, lineY, lineW, lineH);
//    self.line.transform = CGAffineTransformMakeRotation(M_PI_2);

    
    
    
}
// 赋值 
-(void)GetInfo:(MXHomeFasionModel *)model
{
    if (_fashionModelS != model) {
        [_fashionModelS release];
        _fashionModelS = [model retain];
    }
    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:model.pic_url] placeholderImage:[UIImage imageNamed:@"plaseholder"]];
    
    self.titleLabel.text = model.title;
    
    self.descriptionLabel.text = model.bDescription;
    
    self.priceLabel.text = [NSString stringWithFormat:@"¥%@", model.coupon_price];
    
//    self.line.transform = CGAffineTransformMakeRotation(M_PI_2);

}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
